package com.fingard.dsp.bank.directbank.cmb06;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fingard.dsp.bank.directConfig.ActSetItem;
import com.fingard.dsp.bank.directbank.FailCode;
import com.fingard.dsp.bank.directbank.PaymentState;
import com.fingard.dsp.bank.directbank.bankInterface.ISinglePay;
import com.fingard.dsp.bank.directbank.cmb06.interfacelist.CMB06TransCode;
import com.fingard.dsp.bank.reqrespobj.batpayrec.ReqBatPayRec;
import com.fingard.dsp.bank.reqrespobj.batpayrec.RetAtsBatPayRec;
import com.fingard.dsp.bank.reqrespobj.single.*;
import com.fingard.dsp.bank.reqrespobj.single.detail.RetAtsSglDetail;
import com.fingard.net.ConnState;

public class CMB06SinglePay extends CMB06Base implements ISinglePay {
    @Override
    public RetAtsSingle d_1908_SglPay(ReqSingle p_req1908) throws Exception {
        if ("190801".equalsIgnoreCase(p_req1908.reqHeader.commandCode)) {
            return deal_190801_CISPRQA3(p_req1908);
        } else if ("190802".equalsIgnoreCase(p_req1908.reqHeader.commandCode)) {
            return deal_190802_CISPRQA5(p_req1908);
        } else if ("190803".equalsIgnoreCase(p_req1908.reqHeader.commandCode)) {
            return deal_190803_CISPRQA7(p_req1908);
        } else if ("190804".equalsIgnoreCase(p_req1908.reqHeader.commandCode)) {
            return deal_190804_CISPRQA4(p_req1908);
        } else {
            RetAtsSingle retAts = new RetAtsSingle(p_req1908.reqHeader);
            RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail(p_req1908);
            tmpRetDetail.respCode = "0";
            tmpRetDetail.respInfo = "不支持的指令:"+p_req1908.reqHeader.commandCode;
            tmpRetDetail.transState = PaymentState.FAIL_Batch;
            tmpRetDetail.payInfoCode = FailCode.E9981;
            retAts.writeRetDetail(tmpRetDetail);
            return retAts;
        }
    }

    public RetAtsSingle deal_190801_CISPRQA3(ReqSingle p_req1908) throws Exception {
        RetAtsSingle retAts = new RetAtsSingle(p_req1908.reqHeader);
        RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail(p_req1908);

        try {
            ActSetItem actItem = this.getBankConfig().getActSetItem(p_req1908.singleDetail.payAct, "");
            if (actItem == null) {
                tmpRetDetail.respCode = "0";
                tmpRetDetail.respInfo = "未找到账号:[" + p_req1908.singleDetail.payAct+ "]商户配置信息!";
                tmpRetDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                tmpRetDetail.transState = PaymentState.FAIL_Payment;
                tmpRetDetail.payInfoCode = FailCode.E9981;
                retAts.writeRetDetail(tmpRetDetail);
                return retAts;
            }

            JSONObject jsonHeadRequest = new JSONObject();
            jsonHeadRequest.put("xWkeCod", CMB06TransCode.deal_190801_198801_CISPRQA3);

            JSONObject jsonBodyRequest = new JSONObject();
            JSONObject jsonCISPRQA1X0 = new JSONObject();
            jsonCISPRQA1X0.put("xTrnDbn","00");
            jsonCISPRQA1X0.put("xTxnCtf",p_req1908.singleDetail.askNumber);
            jsonCISPRQA1X0.put("xOrdNbr",p_req1908.singleDetail.orderNo);
            jsonCISPRQA1X0.put("xRsvFld","");

            JSONArray jsonCISPRQA1X0Array = new JSONArray();
            jsonCISPRQA1X0Array.add(jsonCISPRQA1X0);

            jsonBodyRequest.put("CISPRQA3X0", jsonCISPRQA1X0Array);

            JSONObject jsonCISPRQA1X1 = new JSONObject();
            jsonCISPRQA1X1.put("xReqTyp","02");
            jsonCISPRQA1X1.put("xMerCod",actItem.merchantId);
            jsonCISPRQA1X1.put("xOrdNbr",p_req1908.singleDetail.orderNo);
            jsonCISPRQA1X1.put("xReqAmt",p_req1908.singleDetail.payAmount);
            jsonCISPRQA1X1.put("xMerMem",p_req1908.singleDetail.askNumber);
            jsonCISPRQA1X1.put("xEffDte",p_req1908.singleDetail.effectDate);
            jsonCISPRQA1X1.put("xBegDte",p_req1908.singleDetail.beginDate);
            jsonCISPRQA1X1.put("xEndDte",p_req1908.singleDetail.endDate);
            jsonCISPRQA1X1.put("xRsvFld","");
            jsonCISPRQA1X1.put("xSubOrd",p_req1908.singleDetail.subOrderFlag);
            jsonCISPRQA1X1.put("xOrdSeq",p_req1908.singleDetail.orderSeq);
            jsonCISPRQA1X1.put("xFleIdx","");

            JSONArray jsonCISPRQA1X1Array = new JSONArray();
            jsonCISPRQA1X1Array.add(jsonCISPRQA1X1);
            jsonBodyRequest.put("CISPRQA3X1", jsonCISPRQA1X1Array);

            JSONObject jsonRequest = new JSONObject();
            jsonRequest.put("HEAD", jsonHeadRequest);
            jsonRequest.put("BODY", jsonBodyRequest);

            String[] tmpStrRet = sendToBank(jsonRequest, actItem, CMB06TransCode.deal_918801_CISPRQA1);

            if (tmpStrRet[0].length() == 0) {
                JSONObject tmpRespJson = JSONObject.parseObject(tmpStrRet[1]);
                JSONObject tmpRespBodyJson = tmpRespJson.getJSONObject("BODY");
                JSONArray jsonCISPRQA1Z1 = tmpRespBodyJson.getJSONArray("CISPRQA3Z1");
                String tmpRespCode = jsonCISPRQA1Z1.getJSONObject(0).getString("zRtnCod");
                tmpRetDetail.respCode = "0";
                tmpRetDetail.transState = tmpRespCode;
                tmpRetDetail.payInfoCode = tmpRespCode;
                tmpRetDetail.respInfo = getBankConfig().getMapValueByKey("respInfoMapping", tmpRespCode);
            } else if (tmpStrRet[0].equals(ConnState.FAIL) || tmpStrRet[0].equals(FailCode.E9981)) {
                tmpRetDetail.respCode = "0";
                tmpRetDetail.respInfo = tmpStrRet[1];
                tmpRetDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                tmpRetDetail.transState = PaymentState.FAIL_Payment;
                tmpRetDetail.payInfoCode = FailCode.E9981;
            } else {
                tmpRetDetail.respCode = "-1";
                tmpRetDetail.respInfo = tmpStrRet[1];
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            tmpRetDetail.respCode = "-1";
            tmpRetDetail.respInfo = ex.getMessage();
            WriteBankLogLn(ex);
        }

        retAts.writeRetDetail(tmpRetDetail);
        return retAts;
    }

    public RetAtsSingle deal_190802_CISPRQA5(ReqSingle p_req1908) throws Exception {
        RetAtsSingle retAts = new RetAtsSingle(p_req1908.reqHeader);
        RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail(p_req1908);

        try {
            ActSetItem actItem = this.getBankConfig().getActSetItem(p_req1908.singleDetail.payAct, "");
            if (actItem == null) {
                tmpRetDetail.respCode = "0";
                tmpRetDetail.respInfo = "未找到账号:[" + p_req1908.singleDetail.payAct+ "]商户配置信息!";
                tmpRetDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                tmpRetDetail.transState = PaymentState.FAIL_Payment;
                tmpRetDetail.payInfoCode = FailCode.E9981;
                retAts.writeRetDetail(tmpRetDetail);
                return retAts;
            }

            JSONObject jsonHeadRequest = new JSONObject();
            jsonHeadRequest.put("xWkeCod", CMB06TransCode.deal_190802_198802_CISPRQA5);

            JSONObject jsonBodyRequest = new JSONObject();
            JSONObject jsonCISPRQA2X0 = new JSONObject();
            jsonCISPRQA2X0.put("xTrnDbn","00");
            jsonCISPRQA2X0.put("xTxnCtf",p_req1908.singleDetail.askNumber);
            jsonCISPRQA2X0.put("xOrdNbr",p_req1908.singleDetail.orderNo);
            jsonCISPRQA2X0.put("xRsvFld","");

            JSONArray jsonCISPRQA1X0Array = new JSONArray();
            jsonCISPRQA1X0Array.add(jsonCISPRQA2X0);

            jsonBodyRequest.put("CISPRQA5X0", jsonCISPRQA1X0Array);

            JSONObject jsonCISPRQA1X1 = new JSONObject();
            jsonCISPRQA1X1.put("xReqTyp","06");
            jsonCISPRQA1X1.put("xMerCod",actItem.merchantId);
            jsonCISPRQA1X1.put("xOrdNbr",p_req1908.singleDetail.orderNo);
            jsonCISPRQA1X1.put("xReqAmt",p_req1908.singleDetail.payAmount);
            jsonCISPRQA1X1.put("xMerMem",p_req1908.singleDetail.askNumber);
            jsonCISPRQA1X1.put("xEffDte",p_req1908.singleDetail.effectDate);
            jsonCISPRQA1X1.put("xBegDte",p_req1908.singleDetail.beginDate);
            jsonCISPRQA1X1.put("xEndDte",p_req1908.singleDetail.endDate);
            jsonCISPRQA1X1.put("xRsvFld","");
            jsonCISPRQA1X1.put("xSubOrd",p_req1908.singleDetail.subOrderFlag);
            jsonCISPRQA1X1.put("xOrdSeq",p_req1908.singleDetail.orderSeq);
            jsonCISPRQA1X1.put("xFleIdx","");

            JSONArray jsonCISPRQA1X1Array = new JSONArray();
            jsonCISPRQA1X1Array.add(jsonCISPRQA1X1);
            jsonBodyRequest.put("CISPRQA5X1", jsonCISPRQA1X1Array);

            JSONObject jsonRequest = new JSONObject();
            jsonRequest.put("HEAD", jsonHeadRequest);
            jsonRequest.put("BODY", jsonBodyRequest);

            String[] tmpStrRet = sendToBank(jsonRequest, actItem, CMB06TransCode.deal_918801_CISPRQA1);

            if (tmpStrRet[0].length() == 0) {
                JSONObject tmpRespJson = JSONObject.parseObject(tmpStrRet[1]);
                JSONObject tmpRespBodyJson = tmpRespJson.getJSONObject("BODY");
                JSONArray jsonCISPRQA1Z1 = tmpRespBodyJson.getJSONArray("CISPRQA5Z1");
                String tmpRespCode = jsonCISPRQA1Z1.getJSONObject(0).getString("zRtnCod");
                tmpRetDetail.respCode = "0";
                tmpRetDetail.transState = tmpRespCode;
                tmpRetDetail.payInfoCode = tmpRespCode;
                tmpRetDetail.respInfo = getBankConfig().getMapValueByKey("respInfoMapping", tmpRespCode);
            } else if (tmpStrRet[0].equals(ConnState.FAIL) || tmpStrRet[0].equals(FailCode.E9981)) {
                tmpRetDetail.respCode = "0";
                tmpRetDetail.respInfo = tmpStrRet[1];
                tmpRetDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                tmpRetDetail.transState = PaymentState.FAIL_Payment;
                tmpRetDetail.payInfoCode = FailCode.E9981;
            } else {
                tmpRetDetail.respCode = "-1";
                tmpRetDetail.respInfo = tmpStrRet[1];
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            tmpRetDetail.respCode = "-1";
            tmpRetDetail.respInfo = ex.getMessage();
            WriteBankLogLn(ex);
        }

        retAts.writeRetDetail(tmpRetDetail);
        return retAts;
    }

    public RetAtsSingle deal_190803_CISPRQA7(ReqSingle p_req1908) throws Exception {
        RetAtsSingle retAts = new RetAtsSingle(p_req1908.reqHeader);
        RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail(p_req1908);

        try {
            ActSetItem actItem = this.getBankConfig().getActSetItem(p_req1908.singleDetail.payAct, "");
            if (actItem == null) {
                tmpRetDetail.respCode = "0";
                tmpRetDetail.respInfo = "未找到账号:[" + p_req1908.singleDetail.payAct+ "]商户配置信息!";
                tmpRetDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                tmpRetDetail.transState = PaymentState.FAIL_Payment;
                tmpRetDetail.payInfoCode = FailCode.E9981;
                retAts.writeRetDetail(tmpRetDetail);
                return retAts;
            }

            JSONObject jsonHeadRequest = new JSONObject();
            jsonHeadRequest.put("xWkeCod", CMB06TransCode.deal_190803_198803_918803_CISPRQA7);

            JSONObject jsonBodyRequest = new JSONObject();
            JSONObject jsonCISPRQA2X0 = new JSONObject();
            jsonCISPRQA2X0.put("xTrnDbn","00");
            jsonCISPRQA2X0.put("xTxnCtf",p_req1908.singleDetail.askNumber);
            jsonCISPRQA2X0.put("xOrdNbr",p_req1908.singleDetail.orderNo);
            jsonCISPRQA2X0.put("xReqTyp","12");
            jsonCISPRQA2X0.put("xReqAmt",p_req1908.singleDetail.payAmount);
            jsonCISPRQA2X0.put("xMerMem","");
            jsonCISPRQA2X0.put("xRsvFld","");

            JSONArray jsonCISPRQA1X0Array = new JSONArray();
            jsonCISPRQA1X0Array.add(jsonCISPRQA2X0);

            jsonBodyRequest.put("CISPRQA7X0", jsonCISPRQA1X0Array);

            JSONObject jsonCISPRQA1X1 = new JSONObject();
            jsonCISPRQA1X1.put("xReqTyp","12");
            jsonCISPRQA1X1.put("xMerCod",actItem.merchantId);
            jsonCISPRQA1X1.put("xOrdNbr",p_req1908.singleDetail.orderNo);
            jsonCISPRQA1X1.put("xReqAmt",p_req1908.singleDetail.payAmount);
            jsonCISPRQA1X1.put("xMerMem",p_req1908.singleDetail.askNumber);
            jsonCISPRQA1X1.put("xEffDte",p_req1908.singleDetail.effectDate);
            jsonCISPRQA1X1.put("xBegDte",p_req1908.singleDetail.beginDate);
            jsonCISPRQA1X1.put("xEndDte",p_req1908.singleDetail.endDate);
            jsonCISPRQA1X1.put("xPlnChg",p_req1908.singleDetail.planChgFlag);
            jsonCISPRQA1X1.put("xPlnBef",p_req1908.singleDetail.planBefore);
            jsonCISPRQA1X1.put("xPlnAft",p_req1908.singleDetail.planAfter);
            jsonCISPRQA1X1.put("xPfqChg",p_req1908.singleDetail.pfqChgFlag);
            jsonCISPRQA1X1.put("xPfqBef",getBankConfig().getMapValueByKey("xPfqMapping", p_req1908.singleDetail.pfqBefore));
            jsonCISPRQA1X1.put("xPfqAft",getBankConfig().getMapValueByKey("xPfqMapping", p_req1908.singleDetail.pfqAfter));
            jsonCISPRQA1X1.put("xBdtChg",p_req1908.singleDetail.bdtChgFlag);
            jsonCISPRQA1X1.put("xBdtBef",p_req1908.singleDetail.bdtBefore);
            jsonCISPRQA1X1.put("xBdtAft",p_req1908.singleDetail.bdtAfter);
            jsonCISPRQA1X1.put("xSexChg",p_req1908.singleDetail.sexChgFlag);
            jsonCISPRQA1X1.put("xSexBef",getBankConfig().getMapValueByKey("xSexMapping", p_req1908.singleDetail.sexBefore));
            jsonCISPRQA1X1.put("xSexAft",getBankConfig().getMapValueByKey("xSexMapping", p_req1908.singleDetail.sexAfter));
            jsonCISPRQA1X1.put("xFeeCha",p_req1908.singleDetail.feeChaFlag);
            jsonCISPRQA1X1.put("xRsvFld","");
            jsonCISPRQA1X1.put("xSubOrd",p_req1908.singleDetail.subOrderFlag);
            jsonCISPRQA1X1.put("xOrdSeq",p_req1908.singleDetail.orderSeq);
            jsonCISPRQA1X1.put("xFleIdx","");

            JSONArray jsonCISPRQA1X1Array = new JSONArray();
            jsonCISPRQA1X1Array.add(jsonCISPRQA1X1);
            jsonBodyRequest.put("CISPRQA7X1", jsonCISPRQA1X1Array);

            JSONObject jsonRequest = new JSONObject();
            jsonRequest.put("HEAD", jsonHeadRequest);
            jsonRequest.put("BODY", jsonBodyRequest);

            String[] tmpStrRet = sendToBank(jsonRequest, actItem, CMB06TransCode.deal_918801_CISPRQA1);

            if (tmpStrRet[0].length() == 0) {
                JSONObject tmpRespJson = JSONObject.parseObject(tmpStrRet[1]);
                JSONObject tmpRespBodyJson = tmpRespJson.getJSONObject("BODY");
                JSONArray jsonCISPRQA1Z1 = tmpRespBodyJson.getJSONArray("CISPRQA7Z1");
                String tmpRespCode = jsonCISPRQA1Z1.getJSONObject(0).getString("zRtnCod");
                tmpRetDetail.respCode = "0";
                tmpRetDetail.transState = tmpRespCode;
                tmpRetDetail.payInfoCode = tmpRespCode;
                tmpRetDetail.respInfo = getBankConfig().getMapValueByKey("respInfoMapping", tmpRespCode);
            } else if (tmpStrRet[0].equals(ConnState.FAIL) || tmpStrRet[0].equals(FailCode.E9981)) {
                tmpRetDetail.respCode = "0";
                tmpRetDetail.respInfo = tmpStrRet[1];
                tmpRetDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                tmpRetDetail.transState = PaymentState.FAIL_Payment;
                tmpRetDetail.payInfoCode = FailCode.E9981;
            } else {
                tmpRetDetail.respCode = "-1";
                tmpRetDetail.respInfo = tmpStrRet[1];
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            tmpRetDetail.respCode = "-1";
            tmpRetDetail.respInfo = ex.getMessage();
            WriteBankLogLn(ex);
        }

        retAts.writeRetDetail(tmpRetDetail);
        return retAts;
    }

    public RetAtsSingle deal_190804_CISPRQA4(ReqSingle p_req1908) throws Exception {
        RetAtsSingle retAts = new RetAtsSingle(p_req1908.reqHeader);
        RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail(p_req1908);

        try {
            ActSetItem actItem = this.getBankConfig().getActSetItem(p_req1908.singleDetail.payAct, "");
            if (actItem == null) {
                tmpRetDetail.respCode = "0";
                tmpRetDetail.respInfo = "未找到账号:[" + p_req1908.singleDetail.payAct+ "]商户配置信息!";
                tmpRetDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                tmpRetDetail.transState = PaymentState.FAIL_Payment;
                tmpRetDetail.payInfoCode = FailCode.E9981;
                retAts.writeRetDetail(tmpRetDetail);
                return retAts;
            }

            JSONObject jsonHeadRequest = new JSONObject();
            jsonHeadRequest.put("xWkeCod", CMB06TransCode.deal_190804_198804_CISPRQA4);

            JSONObject jsonBodyRequest = new JSONObject();
            JSONObject jsonCISPRQA2X0 = new JSONObject();
            jsonCISPRQA2X0.put("xTrnDbn","00");
            jsonCISPRQA2X0.put("xTxnCtf",p_req1908.singleDetail.askNumber);
            jsonCISPRQA2X0.put("xOrdNbr",p_req1908.singleDetail.orderNo);
            jsonCISPRQA2X0.put("xRsvFld","");

            JSONArray jsonCISPRQA1X0Array = new JSONArray();
            jsonCISPRQA1X0Array.add(jsonCISPRQA2X0);

            jsonBodyRequest.put("CISPRQA4X0", jsonCISPRQA1X0Array);

            JSONObject jsonCISPRQA1X1 = new JSONObject();
            jsonCISPRQA1X1.put("xReqTyp","10");
            jsonCISPRQA1X1.put("xMerCod",actItem.merchantId);
            jsonCISPRQA1X1.put("xOrdNbr",p_req1908.singleDetail.orderNo);
            jsonCISPRQA1X1.put("xReqAmt",p_req1908.singleDetail.payAmount);
            jsonCISPRQA1X1.put("xMerMem",p_req1908.singleDetail.askNumber);
            jsonCISPRQA1X1.put("xEffDte",p_req1908.singleDetail.effectDate);
            jsonCISPRQA1X1.put("xBegDte",p_req1908.singleDetail.beginDate);
            jsonCISPRQA1X1.put("xEndDte",p_req1908.singleDetail.endDate);
            jsonCISPRQA1X1.put("xRsvFld","");
            jsonCISPRQA1X1.put("xSubOrd",p_req1908.singleDetail.subOrderFlag);
            jsonCISPRQA1X1.put("xOrdSeq",p_req1908.singleDetail.orderSeq);
            jsonCISPRQA1X1.put("xFleIdx","");

            JSONArray jsonCISPRQA1X1Array = new JSONArray();
            jsonCISPRQA1X1Array.add(jsonCISPRQA1X1);
            jsonBodyRequest.put("CISPRQA4X1", jsonCISPRQA1X1Array);

            JSONObject jsonRequest = new JSONObject();
            jsonRequest.put("HEAD", jsonHeadRequest);
            jsonRequest.put("BODY", jsonBodyRequest);

            String[] tmpStrRet = sendToBank(jsonRequest, actItem, CMB06TransCode.deal_918801_CISPRQA1);

            if (tmpStrRet[0].length() == 0) {
                JSONObject tmpRespJson = JSONObject.parseObject(tmpStrRet[1]);
                JSONObject tmpRespBodyJson = tmpRespJson.getJSONObject("BODY");
                JSONArray jsonCISPRQA1Z1 = tmpRespBodyJson.getJSONArray("CISPRQA4Z1");
                String tmpRespCode = jsonCISPRQA1Z1.getJSONObject(0).getString("zRtnCod");
                tmpRetDetail.respCode = "0";
                tmpRetDetail.transState = tmpRespCode;
                tmpRetDetail.payInfoCode = tmpRespCode;
                tmpRetDetail.respInfo = getBankConfig().getMapValueByKey("respInfoMapping", tmpRespCode);
            } else if (tmpStrRet[0].equals(ConnState.FAIL) || tmpStrRet[0].equals(FailCode.E9981)) {
                tmpRetDetail.respCode = "0";
                tmpRetDetail.respInfo = tmpStrRet[1];
                tmpRetDetail.reqSeqID = p_req1908.singleDetail.askNumber;
                tmpRetDetail.transState = PaymentState.FAIL_Payment;
                tmpRetDetail.payInfoCode = FailCode.E9981;
            } else {
                tmpRetDetail.respCode = "-1";
                tmpRetDetail.respInfo = tmpStrRet[1];
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            tmpRetDetail.respCode = "-1";
            tmpRetDetail.respInfo = ex.getMessage();
            WriteBankLogLn(ex);
        }

        retAts.writeRetDetail(tmpRetDetail);
        return retAts;
    }

    @Override
    public RetAtsSingle d_1944_QrySglPay(ReqQrySingle p_req1944) throws Exception {
        RetAtsSingle retAts = new RetAtsSingle(p_req1944.reqHeader);
        RetAtsSglDetail tmpRetDetail = new RetAtsSglDetail(p_req1944);

        try {
            ActSetItem actItem = this.getBankConfig().getActSetItem(p_req1944.payAct, "");
            if (actItem != null) {
                JSONObject jsonHeadRequest = new JSONObject();
                jsonHeadRequest.put("xWkeCod", CMB06TransCode.deal_1998_9198_CISPRQA0X0);

                JSONObject jsonBodyRequest = new JSONObject();
                JSONObject jsonCISPRQA0X0 = new JSONObject();
                jsonCISPRQA0X0.put("xTrnDbn","00");
                jsonCISPRQA0X0.put("xRsvFld","");

                JSONArray jsonCISPRQA1X0Array = new JSONArray();
                jsonCISPRQA1X0Array.add(jsonCISPRQA0X0);

                jsonBodyRequest.put("CISPRQA0X0", jsonCISPRQA1X0Array);

                // CISPRQA0X1
                JSONObject jsonCISPRQA0X1 = new JSONObject();
                jsonCISPRQA0X1.put("xOrdNbr",p_req1944.orderNo);//订单号
                jsonCISPRQA0X1.put("xTxnCtf",p_req1944.askNumber);//原交易流水号
                jsonCISPRQA0X1.put("xRsvFld","");//预留字段

                JSONArray jsonCISPRQA0X1Array = new JSONArray();
                jsonCISPRQA0X1Array.add(jsonCISPRQA0X1);
                jsonBodyRequest.put("CISPRQA0X1", jsonCISPRQA0X1Array);

                JSONObject jsonRequest = new JSONObject();
                jsonRequest.put("HEAD", jsonHeadRequest);
                jsonRequest.put("BODY", jsonBodyRequest);

                String[] tmpStrRet = sendToBank(jsonRequest, actItem, CMB06TransCode.deal_918801_CISPRQA1);

                if (tmpStrRet[0].length() == 0) {
                    JSONObject tmpRespJson = JSONObject.parseObject(tmpStrRet[1]);
                    JSONObject tmpRespBodyJson = tmpRespJson.getJSONObject("BODY");
                    JSONArray jsonCISPRQA0Z1 = tmpRespBodyJson.getJSONArray("CISPRQA0Z1");
                    tmpRetDetail.respCode = "0";
                    JSONObject jsonResult = jsonCISPRQA0Z1.getJSONObject(0);
                    tmpRetDetail.transState = jsonResult.getString("zPcsSta") + "+" + jsonResult.getString("zFnlRes");
                    tmpRetDetail.payInfoCode = jsonResult.getString("zRspCod");
                    tmpRetDetail.respInfo = getBankConfig().getMapValueByKey("respInfoMapping", jsonResult.getString("zRspCod"));
                } else if (tmpStrRet[0].equals(ConnState.FAIL) || tmpStrRet[0].equals(FailCode.E9981)) {
                    tmpRetDetail.respCode = "0";
                    tmpRetDetail.respInfo = tmpStrRet[1];
                    tmpRetDetail.transState = PaymentState.FAIL_Payment;
                    tmpRetDetail.payInfoCode = FailCode.E9981;
                } else {
                    tmpRetDetail.respCode = "-1";
                    tmpRetDetail.respInfo = tmpStrRet[1];
                    if (tmpStrRet[1].contains("原交易不存在")) {
                        if (canBeNotExist(p_req1944, tmpRetDetail, 45)) {
                            tmpRetDetail.respCode = "0";
                            tmpRetDetail.transState = "E1302+"+tmpStrRet[1];
                            tmpRetDetail.payInfoCode = tmpStrRet[1];
                        }
                    }
                }
            } else {
                tmpRetDetail.respCode = "-1";
                tmpRetDetail.respInfo = "未找到账号:[" + p_req1944.payAct + "]商户配置信息!";
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            tmpRetDetail.respCode = "-1";
            tmpRetDetail.respInfo = ex.getMessage();
            WriteBankLogLn(ex);
        }

        retAts.writeRetDetail(tmpRetDetail);
        return retAts;
    }

    @Override
    public RetAtsSingleBat d_1908BAT_SglBatPay(ReqSingleBat p_req1908BAT) throws Exception {
        return null;
    }

    @Override
    public RetAtsSingleBat d_1944BAT_QrySglBatPay(ReqQrySingleBat p_req1944BAT) throws Exception {
        return null;
    }
}